package com.jxc.jxc01.yk.entity;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

public class PageHelper<E> implements Serializable {
    /**当前页码*/
    private int pageNum;
    /**页容*/
    private int pageSize;
    /**当前页数据*/
    private List<E> data;
    /**总页数*/
    private int pageCount;
    /**总记录数*/
    private int total;
    /**上一页*/
    private int PrePageNum;
    /**下一页*/
    private int NextPageNum;


    public PageHelper() {
        this.pageNum=1;
        this.pageSize=10;
    }

    public PageHelper(int pageNum, int pageSize, List<E> data, int pageCount, int total, int PrePageNum, int NextPageNum) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.data = data;
        this.pageCount = pageCount;
        this.total = total;
        this.PrePageNum = PrePageNum;
        this.NextPageNum = NextPageNum;
    }

    /**
     * 获取
     * @return pageNum
     */
    public int getPageNum() {
        return pageNum;
    }

    /**
     * 设置
     * @param pageNum
     */
    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    /**
     * 获取
     * @return pageSize
     */
    public int getPageSize() {
        return pageSize;
    }

    /**
     * 设置
     * @param pageSize
     */
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    /**
     * 获取
     * @return data
     */
    public List<E> getData() {
        return data;
    }

    /**
     * 设置
     * @param data
     */
    public void setData(List<E> data) {
        this.data = data;
    }

    /**
     * 获取
     * @return pageCount
     */
    public int getPageCount() {
        return total%pageSize==0?total/pageSize:total/pageSize+1;
    }

    /**
     * 设置
     * @param pageCount
     */
    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    /**
     * 获取
     * @return total
     */
    public int getTotal() {
        return total;
    }

    /**
     * 设置
     * @param total
     */
    public void setTotal(int total) {
        this.total = total;
    }

    /**
     * 获取
     * @return PrePageNum
     */
    public int getPrePageNum() {
        return pageNum-1;
    }

    /**
     * 设置
     * @param PrePageNum
     */
    public void setPrePageNum(int PrePageNum) {
        this.PrePageNum = PrePageNum;
    }

    /**
     * 获取
     * @return NextPageNum
     */
    public int getNextPageNum() {
        return pageNum+1;
    }

    /**
     * 设置
     * @param NextPageNum
     */
    public void setNextPageNum(int NextPageNum) {
        this.NextPageNum = NextPageNum;
    }

    public String toString() {
        return "PageHelper{pageNum = " + pageNum + ", pageSize = " + pageSize + ", data = " + data + ", pageCount = " + pageCount + ", total = " + total + ", PrePageNum = " + PrePageNum + ", NextPageNum = " + NextPageNum + "}";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PageHelper<?> that = (PageHelper<?>) o;
        return pageNum == that.pageNum && pageSize == that.pageSize && pageCount == that.pageCount && total == that.total && PrePageNum == that.PrePageNum && NextPageNum == that.NextPageNum && Objects.equals(data, that.data);
    }

    @Override
    public int hashCode() {
        return Objects.hash(pageNum, pageSize, data, pageCount, total, PrePageNum, NextPageNum);
    }
}
